package cuiyt.juc.add;

import java.util.concurrent.CountDownLatch;

/**
 * @author cyt
 * @create 2020-05-01 16:13
 */
public class CountDownLatchDemo {

    // 测试计数器
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 1; i <=10; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName());
                countDownLatch.countDown();
            },String.valueOf(i)).start();
        }
//        countDownLatch.await();
        System.out.println("关门 -> ");

    }
}
